package edu.mobbuzz.web.facade;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.ioc.annotations.Inject;

import edu.mobbuzz.daf.bean.User;
import edu.mobbuzz.daf.dao.IUserDao;



public class AuthorizationFacade extends BaseFacade{
	
	private IUserDao userDao;
	
	
	public IUserDao getUserDao() {
		if(userDao==null)
			userDao = (IUserDao)getFactory().getBean("userDao");
		return userDao;
	}


	public boolean registerUser(String username, String password){
		User _user = new User();
		_user.setUsername(username);
		_user.setPassword(password);
		_user.setStatus(0);
		
		try{
			getUserDao().insert(_user);
			return true;
		}catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
	
	public List<User> getUserList(String where, String order){
		List<User> userList = new ArrayList<User>();
		userList = getUserDao().queryForList(where, order);
		
		return userList;
	}
}
